package com.goodving.guli.bt.weight.family;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.goodving.guli.R;
import com.goodving.guli.bt.Utils;
import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.bt.ui.WeightUserAvatar;
import com.goodving.guli.bt.weight.UserInfo;
import com.goodving.guli.utility.C3657a;


@SuppressLint({"NewApi"})
public class UserInfoImgWithName extends RelativeLayout implements OnClickListener {
    private static final String f11453a;
    private WeightUserAvatar f11454b;
    private TextView f11455c;
    private UserInfo f11456d;
    private C2026k f11457e;

    static {
        f11453a = UserInfoImgWithName.class.getSimpleName();
    }

    public UserInfoImgWithName(Context context) {
        this(context, null, 0);
    }

    public UserInfoImgWithName(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public UserInfoImgWithName(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet);
        View inflate = LayoutInflater.from(context).inflate(R.layout.userimg_with_name, this, true);
        this.f11454b = (WeightUserAvatar) inflate.findViewById(R.id.user_icon);
        this.f11454b.setOnClickListener(this);
        this.f11455c = (TextView) inflate.findViewById(R.id.user_name);
    }

    public void m15842a(int i) {
        this.f11455c.setTextColor(i);
    }

    public void m15843a(Drawable drawable, String str) {
        this.f11454b.setBackground(drawable);
        this.f11455c.setText(str);
    }

    public void m15844a(UserInfo userInfo) {
        if (userInfo != null) {
            GuliLog.tracePrintInfo(f11453a, "bindUser " + userInfo.toString());
            this.f11456d = userInfo;
            m15849b(this.f11456d);
            m15846a(this.f11456d.name);
            return;
        }
        this.f11454b.setBackgroundResource(R.drawable.default_userinfo);
        this.f11455c.setText(C3657a.f18328f);
    }

    public void m15845a(C2026k c2026k) {
        this.f11457e = c2026k;
    }

    public void m15846a(String str) {
        this.f11455c.setText(str);
    }

    public void m15847a(boolean z) {
        this.f11455c.setVisibility(View.GONE);
        if (z) {
            this.f11455c = (TextView) findViewById(R.id.user_name_right);
        } else {
            this.f11455c = (TextView) findViewById(R.id.user_name);
        }
        this.f11455c.setVisibility(View.VISIBLE);
    }

    public void m15848b(int i) {
        this.f11455c.setTextSize((float) i);
    }

    public void m15849b(UserInfo userInfo) {
        this.f11454b.m15374a(Utils.m8048c(userInfo.uid));
        this.f11454b.m15375a(userInfo.name);
        Utils.m8008a(userInfo, this.f11454b);
    }

    public void m15850b(boolean z) {
        this.f11455c.setEnabled(z);
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.user_icon:
                if (this.f11457e != null) {
                    this.f11457e.m15879a(this.f11456d);
                }
            default:
        }
    }
}
